package com.design.FactoryMode.mode1;

import com.design.FactoryMode.demo.*;

/**
 * 定义工厂类
 */
public class SmsCheckFactory {

    /**
     * 创建实例
     * @param type 类型 1：用户注册  2：找回密码  3：修改支付密码   4：提现
     * @return
     */
    public static SmsService createSmsInstance(Integer type ){
        SmsService smsService = null ;
        if(type == 1){
            smsService = new RegisterServiceImpl();
        }else if(type == 2){
            smsService = new ForgetPwdServiceImpl();
        }else if(type == 3){
            smsService = new PayPwdServiceImpl();
        }else if(type == 4){
            smsService = new WithdrawServiceImpl();
        }else{
            throw  new RuntimeException("没有找到指定的短信验证码类型");
        }
        return smsService;
    }

}
